package com.soft.cqlinglong.oto.web.permission;
import com.soft.cqlinglong.oto.dao.model.TSMenu;
import com.soft.cqlinglong.oto.service.permission.TSMenuService;
import com.soft.cqlinglong.oto.web.BaseController;
import com.soft.cqlinglong.oto.web.interceptor.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * 菜单层显示层
 * @author 黄学乾 778142659@qq.com
 * @create 2017-06-11 10:04
 **/
@Controller
@RequestMapping("system/tsMenu")
public class TSMenuController extends BaseController {

    @Autowired(required = false)
    private TSMenuService tsMenuService ;


    /**
     * 跳转至菜单新增界面
     */
    @Permission
    @RequestMapping({"sitemesh/tsMenuList", "nositemesh/tsMenuList"})
    public ModelAndView tsMenuList() {
        ModelAndView tsMenuAdd = new ModelAndView("permission/tsMenuList");
        this.common(tsMenuAdd);
        return tsMenuAdd;
    }

    /**
     * 跳转至菜单新增界面
     */
    @Permission
    @RequestMapping({"sitemesh/tsMenuAdd", "nositemesh/tsMenuAdd"})
    public ModelAndView tsMenuAdd() {
        ModelAndView tsMenuAdd = new ModelAndView("/permission/tsMenuAdd");
        common(tsMenuAdd);
        return tsMenuAdd;
    }

    /**
     * 跳转至菜单修改界面
     */
    @Permission
    @RequestMapping({"sitemesh/tsMenuModify", "nositemesh/tsMenuModify"})
    public ModelAndView tsMenuModify() {
        ModelAndView tsMenuModify = new ModelAndView();

        return tsMenuModify;
    }

    /**
     * 跳转至菜单详情界面
     */
    @Permission
    @RequestMapping({"sitemesh/tsMenuDetails", "nositemesh/tsMenuDetails"})
    public ModelAndView tsMenuDetails() {
        ModelAndView tsMenuDetails = new ModelAndView();

        return tsMenuDetails;
    }

    @RequestMapping({"sitemesh/tsMenuSave", "nositemesh/tsMenuSave"})
    @ResponseBody
    public Map<String, Object> tsMenuSave(TSMenu tsMenu) {
        Map<String, Object> responseCode = new HashMap<String, Object>();
        try {
            tsMenuService.saveTSMenu(tsMenu);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseCode;
    }

    @RequestMapping({"sitemesh/tsMenuUpdate", "nositemesh/tsMenuUpdate"})
    @ResponseBody
    public Map<String, Object> tsMenuUpdate() {
        Map<String, Object> responseCode = new HashMap<String, Object>();
        return responseCode;
    }

}
